package birdsong.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import FollowME.ServerToClientMessage;
import birdsong.comm.ClientSideMessage;
import birdsong.comm.ClientSideMessage.Type;

public class ServerToClientMessageTest {

	private static final Type typeBirdsongMessage = Type.BIRDSONG_MESSAGE;

	private static final String NICKNAME = "ETI";
	private static final String PAYLOAD = "ERROR - Socket closed!";

	private ServerToClientMessage nullMessage;
	private ServerToClientMessage message;

	@Before
	public void setUp() throws Exception {
		message = new ServerToClientMessage(typeBirdsongMessage, PAYLOAD,
				NICKNAME);
	}

	@Test
	public void testServerToClientMessageTest() {
		assertNull("The message: 'nullMessage' was not initialized",
				nullMessage);
		assertNotNull("The message: 'message' was initialized", message);

		assertEquals(typeBirdsongMessage, message.getType());
		assertEquals(PAYLOAD, message.getPayload());
		System.err.println(message.getSendersNickname());
		assertEquals(NICKNAME, message.getSendersNickname());
	}

	@Test
	public void testGetType() {
		assertNotNull(message.getType());
		assertEquals(typeBirdsongMessage, message.getType());

	}

	@Test
	public void testGetPayload() {
		assertNotNull(message.getPayload());
		assertEquals(PAYLOAD, message.getPayload());
	}

	@Test
	public void testGetSendersNickname() {
		assertNotNull(message.getSendersNickname());
		assertEquals(NICKNAME, message.getSendersNickname());
	}
}